async function* asyn_func() {
    for (let i = 0; i <= 5; i++) {
        // pause 1 second
        await new Promise(resolve => setTimeout(resolve, 1000))
        yield i
    }
}

let af = asyn_func()

for await (let value of af) {
    console.log(value)
}